package com.lmt_11;

import java.awt.image.ImageProducer;
import java.util.*;

public class MapTest3 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        String select[] = new String[]{"A","B","C","D"};
        Random random = new Random();
        ;
        for (int i = 0; i < 80; i++){
           int index = random.nextInt(4);
           list.add(select[index]);
        }
        //System.out.println(list);
        Map<String,Integer> res = new HashMap<>();
        for (String s : list) {
            if (res.containsKey(s)){
                Integer i = res.get(s);
                res.put(s, ++i);
            }
            else{
                res.put(s,1);
            }
        }
        res.forEach((k,v)-> System.out.println(k+" "+v));
    }
}
